Skip to content

feat(iam): add public cached GET /v1/iam/stats aggregate endpoint - #89

Merged
zeekay merged 1 commit into
hanzoai:mainfrom
zeekay:feat/iam-public-stats
Nov 27, 2026
Merged

zeekay merged 1 commit into
hanzoai:mainfrom
zeekay:feat/iam-public-stats

Conversation

@zeekay

@zeekay zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Add typed public endpoint GET /v1/iam/stats (apps/iam/stats.go) returning {"users": <int64>, "organizations": <int64>} with zero PII.
  • Exclude soft-deleted users (IsDeleted == true), cache counts in-process for 5 minutes (keyed per orm.DB instance), return Cache-Control: public, max-age=300, s-maxage=300, stale-while-revalidate=3600, and fail closed with HTTP 503 when the identity store is unavailable.
  • Register /v1/iam/stats in apps/iam/contract_test.go (authztest.Open) and internal/host/build.go (publicCatalog, 300s shared edge copy).
  • Regenerate apps/iam/zipdoc_gen.go via go generate ./apps/iam.
  • Add unit tests TestPublicStatsCountsLiveUsersAndOrgs and TestPublicStatsDegradedReturns503.

Validation

  • go generate ./apps/iam
  • go test -race -count=1 ./apps/iam/... (including TestAuthorizationContract, TestComposingRecoveredTheNestedRegistry, TestPublicStats*)
  • go test -count=1 ./internal/host -run 'Test.*(Cache|Shared|Catalog|CORS)'
  • go test -count=1 ./manifest/...

Expose public, zero-PII aggregate counts of active Hanzo IAM users and
organizations at GET /v1/iam/stats (5m in-process cache, public
Cache-Control s-maxage=300 / stale-while-revalidate=3600, fail-closed
HTTP 503 when store is unavailable). Add /v1/iam/stats to publicCatalog
and authztest open floors so callers like forge.hanzo.ai can display the
real account total instead of local seat counts.

Co-authored-by: Hanzo Dev <dev@hanzo.ai>
@zeekay
zeekay merged commit 9818223 into hanzoai:main Nov 27, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant